package com.winit.common.websocket.handler;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

/**
 * 握手
 * @author wangjian
 *
 */
@Component
public class MyHandshakeInterceptor implements HandshakeInterceptor {

	private static final Logger logger = LoggerFactory.getLogger(MyHandshakeInterceptor.class);
	
	public boolean beforeHandshake(ServerHttpRequest request , ServerHttpResponse response,
			WebSocketHandler wsHandler,Map<String, Object> attributes) throws Exception{
		if (request instanceof ServletServerHttpRequest) {
            logger.info("Before Handshake.......");
		}
		return true;
	}
	
	public void afterHandshake(ServerHttpRequest request,ServerHttpResponse response,WebSocketHandler wsHandler,Exception ex){
	}

}
